var objExport = document.getElementById("export_obj");
var stlExport = document.getElementById("export_stl");

objExport.addEventListener("click",function(){
	var object = activeObject;

		if ( object === null ) {
			alert( 'No object selected.' );
			return false;;
		}

		var exporter = new THREE.OBJExporter();

		saveString( exporter.parse( object ), object.name + '.obj' );
		return false;
});

stlExport.addEventListener("click",function(){
	var object = activeObject;

		if ( object === null ) {
			alert( 'No object selected.' );
			return false;;
		}

		var exporter = new THREE.STLExporter();

		saveString( exporter.parse( object ), object.name + '.stl' );
		return false;
});

function saveString( text, filename ) {

		save( new Blob( [ text ], { type: 'text/plain' } ), filename );

	}
var link = document.createElement( 'a' );
	link.style.display = 'none';
	document.body.appendChild( link );
function save( blob, filename ) {

		link.href = URL.createObjectURL( blob );
		link.download = filename || 'data.json';
		link.click();
}